import cv2

img = cv2.imread(r"/\images\008.jpg")
h, w = img.shape[0], img.shape[1]

angle = 1
scale = 1
f = -1
while True:
    m = cv2.getRotationMatrix2D((h / 2, w / 2), -angle, scale + f * 0.1)
    angle = (angle + 10) % 360
    scale = scale + f * 0.1
    if scale < 0.1 or scale >= 1:
        f *= -1
    img1 = cv2.warpAffine(img, m, (w, h))
    key = cv2.waitKey(100)
    if key == 27:
        break
    cv2.imshow("test", img1)
cv2.destroyAllWindows()